<% content_for :title, "Liste des ordinateurs" %>
<%= javascript_include_tag :defaults %>
<script type="text/javascript">
		jQuery(document).ready(function() {
			// Initialise Plugin
			var options = {
				additionalFilterTriggers: [jQuery('#quickfind')]
			};
			jQuery('#demotable').tableFilter();
		});
	</script> 

<h1>Liste des ordinateurs</h1>

<table id='demotable'>
		
<thead>
  <tr>
    <th>Nom</th>
    <th>Adresse mac</th>
    <th>Adresse IP</th>
    <th>Ram</th>
    <th>Cpu</th>
    <th>Disque dur</th>
    <th filter='false'>Etat du PC</th>
    <th filter='false'>Etat de l'agent</th>
    <th filter='false'>Actions</th>
  </tr>
</thead>

<tbody>
<% @computers.each do |computer| %>
  <tr>
    <td><%=h computer.name %></td>
    <td><%=h computer.mac_adress %></td>
    <td><%=h computer.ip_computer %></td>
    <td><%=h computer.ram %>Mo</td>
    <td><%=h computer.cpu %>Ghz</td>
    <td><%=h computer.hard_drive %>Go</td>
    <td>
    	 <% if computer.state_computer %>
					<%= image_tag "icons/active.png", :id=>"computer_state_#{computer.id}" %>
				 <% else %>
					<%= image_tag "icons/inactive.png", :id=>"computer_state_#{computer.id}" %>
				<% end %>
    </td>
    <td>
    	<% if computer.state_agent %>
			<%= image_tag "icons/active.png", :id=>"agent_state_#{computer.id}" %>
		<% else %>
			<%= image_tag "icons/inactive.png", :id=>"agent_state_#{computer.id}" %>
		<% end %>
    </td>
    <td>
    <%= link_to image_tag("icons/zoom.png", :title=>"Afficher"), computer %>
    <% if current_user %>
    <%= link_to image_tag("icons/edit.png", :title=>"Modifier"),edit_computer_path(computer) %>
    <%= link_to image_tag("icons/delete.png", :title=>"Supprimer"), computer, :confirm => 'Voulez-vous vraiment supprimer cet ordinateur ?', :method => :delete %>
    <% end %>
    </td>

<script type="text/javascript">

          jQuery('#demotable').tablePagination({});

</script> 
  </tr>
<% end %>
</tbody>
</table>

<br />

<%= link_to "Ajouter un ordinateur",
            new_computer_path,
            :class => "button add"
            %>
